package com.itdct.onflow.generator.model

import com.alibaba.fastjson2.annotation.JSONField
import com.itdct.onflow.core.entity.IdEntity
import kotlin.reflect.KClass

/**
 * @author DCTANT
 * @date 2021/11/14 23:05:55
 * @version 1.0
 * @description
 */
class FieldModel {
    @JSONField(serialize = false)
    var clazz: Class<*>? = null
    var className = ""

    @JSONField(serialize = false)
    var kClass: KClass<*>? = null
    var name = ""
    var nameBigCamel = ""
    var typeName = ""
    var columnName = ""
    var comment = ""
    var length = 0
    var unique = false
    var nullable = false
    var autoincrement = false
    var defaultValue = ""
    var decimal = 0
    var indexed = false
    var primaryKey = false
    var dbType = ""
    var sort = 0
    var ddl = ""

    @JSONField(serialize = false)
    var vueType = ""
    var virtual = false

    /**
     * 排序规则
     */
    var collate = ""

    /**
     * 字符集
     */
    var charset = ""

    val annotationList = ArrayList<AnnotationModel>()

    // INFO: Zhouwx: 2025/3/26 关联字典信息
    var dictCode = ""
    var dictGenSuffix = "Name"

    // INFO: Zhouwx: 2025/3/26 关联其他类信息
    @JSONField(serialize = false)
    var targetClass: KClass<out IdEntity>? = null
    var targetClassName: String? = null
    var targetEntityClassName: String? = null
    var targetWholeClassName: String? = null

    /**
     * 目标类的表名
     */
    var targetClassTableName: String? = null

    /**
     * 目标类的表名缩写，这个值为动态产生，不记录到log中
     */
    @JSONField(serialize = false)
    var targetTableNameAbbr: String? = null

    /**
     * 对方类的字段名
     */
    var targetColumnName: String? = null

    var targetFieldName = ""
    var idGenSuffix = "Name"

    // INFO: Zhouwx: 2025/8/12 是否生成下拉选
    var forSelect = false

    /**
     * 该字段是否支持排序
     */
    var sortable = false

    /**
     * 联合索引
     */
    var relateIndex = ArrayList<String>()

    /**
     * 联合唯一索引
     */
    var relateUnique = ArrayList<String>()

    /**
     * 该字段在vue组件中的类型
     */
    @JSONField(serialize = false)
    var vueComponentType = ""

}